import { BaseMod } from "../../base/BaseMod";
import { loginMod } from "../login/LoginMod";
import { MsgId, MsgToc } from "../../cfg/Msg";
import { popupMgr } from "../../com/PopupMgr";

/**
 * 创角模块
 */
export const createRoleMod = _ as CreateRoleMod;
export class CreateRoleMod extends BaseMod {

    onInit(): void {
        (createRoleMod as any) = this;
        this.onMsg(MsgId.createRole, this.tocCreateRole);
    }

    tosCreateRole(name: string, cid: number) {
        this.sendMsg(MsgId.createRole, { name, cid });
    }

    tocCreateRole(data: MsgToc[MsgId.createRole]) {
        let { code, msg } = data;
        if (code) return popupMgr.showFloatText(msg);
        loginMod.tosJoinGame();
    }

}